//
//  VideoPlayerView.swift
//  dkqsy
//
//  Created by Macintosh on 2024/1/6.
//

import UIKit

class VideoPlayerView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(self.playBgView)
        self.playBgView.snp.makeConstraints { make in
            make.left.right.top.bottom.equalTo(0)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var player: SJVideoPlayer? {
        didSet {
            if let player = player {
                playBgView.subviews.forEach({ $0.removeFromSuperview() })
                playBgView.addSubview(player.view)
                player.view.snp.makeConstraints { make in
                    make.left.right.top.bottom.equalTo(0)
                }
            }
        }
    }

    lazy var playBgView: UIView = {
        let view = UIView()
        
        return view
    }()

}
